/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flexengine.server;

import java.io.Serializable;

/**
 * @author Luann R. Athayde
 * @version 1.0
 * @since 1.0
 */
public class FlexMessage implements Serializable, Cloneable {
    
    private long         id;
    private double       action;
    private Serializable message;

    public FlexMessage(double action, Serializable message) {
        this.id = -1;
        this.action = action;
        this.message = message;
    }

    public FlexMessage() {
        this(0,null);
    }

    protected void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public double getAction() {
        return action;
    }

    public void setAction(double action) {
        this.action = action;
    }

    public Serializable getMessage() {
        return message;
    }

    public void setMessage(Serializable message) {
        this.message = message;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FlexMessage other = (FlexMessage) obj;
        return this.id == other.id;
    }
    
    @Override
    public FlexMessage clone() {
        FlexMessage msg = new FlexMessage(action, message);
        msg.setId(id);
        return msg;
    }
    
    @Override
    public String toString() {
        return "FlexMessage{" + "id=" + id + ", action=" + action + ", message=" + message + '}';
    }
    
}
